package com.biaobiaoqi.scoreanalysis.administrator.action;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.biaobiaoqi.scoreanalysis.exception.NoSuchEntityFoundException;
import com.biaobiaoqi.scoreanalysis.service.IAdministratorService;
import com.opensymphony.xwork2.ActionSupport;

public class DeleteAdmin extends ActionSupport {
 	private static final long serialVersionUID = -5225718370619119177L;
 	private static final Log log = LogFactory.getLog(DeleteAdmin.class);
 	private int id;
 	@Resource
 	private IAdministratorService administratorService;
 	
 	public String execute() {
 		log.debug("delete admin:"+id);
 		try {
			administratorService.deleteAdministrator(id);
			return SUCCESS;
		} catch (NoSuchEntityFoundException e) {
			log.error("delete admin failed.", e);
			addActionError("服务器内部错误");
			return ERROR;
		} catch (Exception e) {
			log.error("delete admin failed.",e);
			addActionError("服务器内部错误");
			return ERROR;
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public IAdministratorService getAdministratorService() {
		return administratorService;
	}

	public void setAdministratorService(IAdministratorService administratorService) {
		this.administratorService = administratorService;
	}
}
